﻿using MediatR;
using SheepStorage.API.Application.Command.SheepManagementCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Domain.DTO.Output;
using SheepStorage.Domain.Entity;
using SheepStorage.Service.DataImp;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.SheepManagementHandler
{
    public class SheepManagementListCommandHandler : IRequestHandler<SheepManagementListCommand, Results<PageOutput<SheepManagement>>>
    {

        private readonly ISheepManagementService sheepManagementService;

        public SheepManagementListCommandHandler(ISheepManagementService sheepManagementService)
        {
            this.sheepManagementService = sheepManagementService;
        }

        /// <summary>
        /// 羊场显示
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<PageOutput<SheepManagement>>> Handle(SheepManagementListCommand request, CancellationToken cancellationToken)
        {
            return Results<PageOutput<SheepManagement>>.DataResult(await sheepManagementService.GetSheepManagement(request.SheepYardName, request.SheepDuty,request.pageIndex,request.pageSize));
        }


    }
}
